Conversation
|
can you add a compliance check here: https://github.com/networktocode/netutils/tree/develop/tests/unit/mock/config/compliance/compliance I am interested to see how you define the scope of the configs when there is a space at the start of the line, and would ask that we consider how that will work with GC |
Hmm, ok. In that case I'd probably just |
That may come with other issues for compliance or remediation. Once you put in a compliance test I will take a look at how it works. Pinging @jeffkala on this as well. |
|
Ok, I have added the compliance tests as requested. I have also changed the parser to allow the following to be equivalent so that you don't need to format the intended config in the same manner as the backup config (always separate sections by comments): |
| @@ -0,0 +1,208 @@ | |||
| # | |||
| sysname NTC-Router | |||
There was a problem hiding this comment.
Shouldn't the intended be the same spatially aware configs as the backup?
There was a problem hiding this comment.
I made it space agnostic for single config lines. Both work. Do you want to require that the intended config match the space exactly?
There was a problem hiding this comment.
Do you want to require that the intended config match the space exactly?
I don't know for sure. I just want to be purposeful and consider how it effects GC.
There was a problem hiding this comment.
We met internally about this. The conclusion is the following:
- We will not
lstripany lines - If the backup has a leading space, the config will be parsed with it
- Any intended configuration will be required to match exactly (including any leading spaces)
- Intended configuration will also require
#symbols as they are used to distinguish new sections of configuration
| # | ||
| tftp client source interface M-GigabitEthernet0/0/0 | ||
| # | ||
| header motd % |
There was a problem hiding this comment.
Is header actually indented 1 space? Seems odd that its nested under seemingly the acl parent?
| # | ||
| tftp client source interface M-GigabitEthernet0/0/0 | ||
| # | ||
| header motd % |
There was a problem hiding this comment.
same as previous find this weird and want to make sure this is truly 1 space'd in...in the backup from the device.
|
@itdependsnetworks and @jeffkala I have updated the parsing to include the leading spaces. Parsing exampleBackupParsed ConfigLineConfigLine(config_line=" sysname NTC123456", parents=()),The compliance, however is automatically stripping leading spaces here: netutils/netutils/config/compliance.py Line 471 in 24c40b6 As such, compliance for single config lines don't have leading spaces unless we refactor the Compliance exampleBackupIntendedCompliance "sysname": {
"compliant": false,
"missing": "sysname NTC-Router",
"extra": "sysname NTC123456",
"cannot_parse": true,
"unordered_compliant": false,
"ordered_compliant": false,
"actual": "sysname NTC123456",
"intended": "sysname NTC-Router"
}, |
|
okay, likely can move forward with this PR, but then will have to circle back for the full strip challenge. Will sync with Jeff before merging. |
* Changed stripping whitespace for specific network_os

Closes: #752
NTC-4804
This PR adds a more robust config example as well as some edge cases for the HP Comware platform and adds a custom parser method to properly parse the different sections.
I also was confused which class to update initially, but then I noticed that the HPComwareConfigParser class wasn't really doing much by itself and was redundant. I consolidated the two classes and then added some deprecation warnings and updated the parser to directly use the HPEConfigParser class.